# Maintainer: Bruno Pagani <archange@archlinux.org>

pkgname=openvkl
pkgver=1.3.2
pkgrel=3
pkgdesc="Intel® Open Volume Kernel Library"
arch=(loong64 x86_64)
url="https://www.openvkl.org/"
license=(Apache)
depends=(embree gcc-libs glibc onetbb openvdb rkcommon)
makedepends=(boost cmake ispc)
source=(
  https://github.com/openvkl/openvkl/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
  $pkgname-1.3.2-duplicate_header.patch
)
sha256sums=('7704736566bf17497a3e51c067bd575316895fda96eccc682dae4aac7fb07b28'
            'e228a8bfb95bb7fb8bfae100b22b529c29cec16594f8ef5a63373dc138988a37')

prepare() {
  # prevent version.h to be installed twice (and to the wrong location)
  # https://github.com/openvkl/openvkl/issues/19
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-1.3.2-duplicate_header.patch
}

build() {
  cmake -B build -S ${pkgname}-${pkgver} \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DBUILD_EXAMPLES=OFF \
    -DOpenVDB_ROOT=/usr \
    -Wno-dev
  cmake --build build --verbose
}

check() {
  LD_LIBRARY_PATH="${PWD}"/build ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="${pkgdir}" cmake --install build
}
